//
//  LZCouponListModel.m
//  laziz_Merchant
//
//  Created by xbnzd on 16/12/25.
//  Copyright © 2016年 XBN. All rights reserved.
//

#import "LZCouponListModel.h"
#import "MJProperty.h"
#import "LZDateFormatterManager.h"

@implementation LZCouponListModel
+ (NSDictionary *)mj_replacedKeyFromPropertyName{
    return @{
             @"couponId" : @"id",
             };
}

- (id)copyWithZone:(NSZone *)zone
{
    LZCouponListModel *mm = [[LZCouponListModel allocWithZone:zone] init];
    mm.nowTime = self.nowTime;
    mm.couponId = self.couponId;
    mm.sellerId = self.sellerId;
    mm.restaurantName = self.restaurantName;
    mm.videoUrl = self.videoUrl;
    mm.videoPhoto = self.videoPhoto;
    mm.promotionTitle = self.promotionTitle;
    mm.promotionFood = self.promotionFood;
    mm.tag = self.tag;
    mm.profile = self.profile;
    mm.state = self.state;
    mm.isDelete = self.isDelete;
    mm.couponsName = self.couponsName;
    mm.couponsMoney = self.couponsMoney;
    mm.couponsRatio = self.couponsRatio;
//    mm.couponsOrigin = self.couponsOrigin;
    mm.couponsUseConditions = self.couponsUseConditions;
    mm.couponsTotalCount = self.couponsTotalCount;
    mm.couponsUsedCount = self.couponsUsedCount;
    mm.couponsGetCount = self.couponsGetCount;
    mm.couponsStartTime = self.couponsStartTime;
    mm.couponsEndTime = self.couponsEndTime;
    mm.couponsExceptTime = self.couponsExceptTime;
    mm.couponsStartDaytime = self.couponsStartDaytime;
    mm.couponsEndDaytime = self.couponsEndDaytime;
    mm.couponsRemindAppoint = self.couponsRemindAppoint;
    mm.couponsRemindRule = self.couponsRemindRule;
    mm.grouponName = self.grouponName;
    mm.grouponFoods = self.grouponFoods;
    mm.grouponBeforeCost = self.grouponBeforeCost;
    mm.grouponAfterCost = self.grouponAfterCost;
//    mm.grouponOrigin = self.grouponOrigin;
    mm.grouponCount = self.grouponCount;
    mm.grouponFinishCount = self.grouponFinishCount;
    mm.grouponDeadline = self.grouponDeadline;
    mm.grouponEndTime = self.grouponEndTime;
    mm.grouponExceptTime = self.grouponExceptTime;
    mm.grouponStartDaytime = self.grouponStartDaytime;
    mm.grouponEndDaytime = self.grouponEndDaytime;
    mm.grouponRemindAppoint = self.grouponRemindAppoint;
    mm.grouponRemindRule = self.grouponRemindRule;
    mm.likesCount = self.likesCount;
    mm.storeCount = self.storeCount;
    mm.shareCount = self.shareCount;
    mm.remarkCountPerson = self.remarkCountPerson;
    mm.remarkCountScore = self.remarkCountScore;
    mm.playCount = self.playCount;
    
    return mm;
}

- (id)mj_newValueFromOldValue:(id)oldValue property:(MJProperty *)property
{
    if ([oldValue isKindOfClass:[NSNull class]]){
        return @"";
    }
    
    if ([property.name isEqualToString:@"couponsStartDaytime"] || [property.name isEqualToString:@"couponsEndDaytime"] || [property.name isEqualToString:@"grouponStartDaytime"] || [property.name isEqualToString:@"grouponEndDaytime"]) {
        if (oldValue != nil) {
            NSString *ss = (NSString *)oldValue;
            if (ss.length > 0) {
                return [[LZDateFormatterManager shareInstance] stringFromStringNormalHaveLineHHmm:ss];
            }
        }
    }
    
    return oldValue;
}

// 获取团购类型每天的有效期
- (NSString*)getGroupEverydayValid {
    NSString *everyDayValid = nil;
    if ([LZLanguageManager shareInstance].getLanguageType == LanguageType_Ar) {
        everyDayValid = [NSString stringWithFormat:@"%@ - %@",self.grouponEndDaytime,self.grouponStartDaytime];
    }
    else {
        everyDayValid = [NSString stringWithFormat:@"%@ - %@",self.grouponStartDaytime,self.grouponEndDaytime];
    }
    return everyDayValid;
}

// 获取优惠券类型每天的有效期
- (NSString*)getCouponEverydayValid {
    NSString *everyDayValid = nil;
    if ([LZLanguageManager shareInstance].getLanguageType == LanguageType_Ar) {
        everyDayValid = [NSString stringWithFormat:@"%@ - %@",self.couponsEndDaytime,self.couponsStartDaytime];
    }
    else {
        everyDayValid = [NSString stringWithFormat:@"%@ - %@",self.couponsStartDaytime,self.couponsEndDaytime];
    }
    return everyDayValid;
    
}

@end
